<%@ page session="false" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>

<h:panelGroup>
	<fieldset>
	<legend>
	<h:panelGroup>
		<tr:commandLink action="#{orderController.addProductToOrder}"
						rendered="#{empty productBean.order}" shortDesc="Dołącz do zamówienia">
				<tr:image source="gfx/save_button.png" />
		</tr:commandLink>
		<tr:commandLink action="#{orderController.saveProductItem}"
						rendered="#{not empty productBean.order}" shortDesc="Zapisz zmiany">
				<tr:image source="gfx/save_button.png" />
		</tr:commandLink>
	</h:panelGroup>
	</legend>
	<table width="100%" border="0">
	<tr>
	<td colspan="4" align="center">
	<h3>Dane produktu</h3>
	</td>
	</tr>
		<tr>
			<td align="right">
				<h:outputText value="Kod/nazwa:" />
				</td>
			<td width="30%">
				<tr:inputText id="productCode"
								value="#{productBean.code}" shortDesc="Kod towaru"
								required="true" maximumLength="70"
								requiredMessageDetail="Kod jest wymagany"
								contentStyle="width:100%;display:block;" /> 
			</td>

			<td align="right">
				<h:outputText value="Cena jednostkowa:" />
			</td>
			<td width="25%">
				<tr:inputText id="unitpriceList"
								value="#{productBean.unitPrice}" required="true" simple="true"
								requiredMessageDetail="Cena jednostkowa za zaproszenie jest wymagana"
								contentStyle="width:100%;">
						<f:convertNumber groupingUsed="false" maxFractionDigits="2"
										minFractionDigits="2" locale="pl" />
				</tr:inputText> 
					<h:message for="unitpriceList" styleClass="validation_info" />
			</td>
		</tr>
		<tr>
			<td align="right">
				<h:outputText value="Całkowita ilość:" />
			</td>
			<td width="30%">
			<tr:inputText id="totalCount"
						value="#{productBean.totalCount}" shortDesc="Całkowita ilość"
						required="false" simple="true"
						requiredMessageDetail="Ilość musi być większa od 0"
						contentStyle="width:100%;display:block;">
				<f:convertNumber integerOnly="true" />
			</tr:inputText> 
				<tr:message for="totalCount" styleClass="validation_info" />
			</td>

			<td align="right"></td>
			<td></td>
		</tr>
		<tr>
			<td align="right">Uwagi:</td>
			<td colspan="3">
				<tr:inputText columns="40" rows="4" value="#{productBean.note}" 
							shortDesc="Uwagi dodatkowe" simple="true"
							contentStyle="width:100%" />
			</td>
		</tr>
		<tr>
			<td colspan="2" align="left"></td>
			<td colspan="2" align="right"></td>
		</tr>
	</table>

	</fieldset>
</h:panelGroup>